﻿@model ARMS.Models.BookingAdpter
@using System.Web.Mvc

@{
    ViewBag.Title = "Search for booking";
}

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>

<div>
@{
    List<SelectListItem> services = (List<SelectListItem>) ViewData.Eval(ARMS.BaseClasses.Factory.LSERVICES);
    ARMS.Models.Shop shop = (ARMS.Models.Shop) ViewData.Eval(ARMS.BaseClasses.Factory.CSHOP);
    string shopName = (shop != null) ? String.Format("{0} - {1}", shop.id, shop.name) : "";
}
</div>
<h2>Search for a booking</h2>

<div id="shopinfo">
    Shop: @{ @Html.Raw(String.Format("<span>{0}</span>", shopName)); }
</div>

@Html.ValidationSummary(false, "Please correct the errors and try again.")

@using(Html.BeginForm("SearchBooking", "Booking"))
{
<fieldset>
    <div class="detail">
    @{
        @Html.Label("bookingid", "Booking ID");
        @Html.TextBox("id", "", new { @id = "bookingid", @name = "bookingid", @value = -1 });
        @Html.Raw("<br/>");

        @Html.Label("customerid", "Customer ID");
        @Html.TextBoxFor(m => m.customerid);
        @Html.Raw("<span> OR Customer name:</span>");
        @Html.TextBoxFor(m => m.customername);
        @Html.Raw("<br />");

        @Html.Label("serviceid", "Service ID");
        @Html.DropDownList("serviceid", services, String.Empty, new {@readonly = true} )
        @Html.Raw("<br />");

        @Html.Label("Use datetime filter (check)");
        @Html.CheckBox("usetimeframe", false);
        @Html.Raw("<br />");

        @Html.LabelFor(m => m.instance.datestamp);
        @Html.TextBox("datestampfrom", Model.instance.datestamp, new { @type = "datetime-local" } );
        @Html.Raw("<br />");

        @Html.LabelFor(m => m.instance.datestamp);
        @Html.TextBox("datestampto", Model.instance.datestamp, new { @type = "datetime-local" });
        @Html.Raw("<br />");

        bool active = Model.instance.active;

        List<SelectListItem> bookingStatus = new List<SelectListItem>();
        bookingStatus.Add(new SelectListItem() { Value = "1", Text = "Scheduled", Selected = active });
        bookingStatus.Add(new SelectListItem() { Value = "0", Text = "Not Scheduled", Selected = !active });

        @Html.LabelFor(m => m.instance.active);
        @Html.DropDownList("active", bookingStatus);

        @Html.HiddenFor(m => m.shopid);
    }
    </div>
    <div class="detail buttons">
        <button class="dialog-btn" id="cancel" type="button" value="Cancel">@{ @Html.ActionLink("Cancel", "Index", "Booking"); }</button>
        <button class="dialog-btn" id="save" type="submit" value="Save">Save</button>
    </div>
</fieldset>
<div class="instruction clear">
    * mandatory fields.<br /><br />
</div>
<div class="instruction clear">
    <h4>Process of searching for the booking consit of multiple options:</h4>
    <ul>
        <li>Find by booking number</li>
        <li>Find by the membership number or customer name</li>
        <li>Or by the service</li>
        <li>Find by booking date</li>
    </ul>
</div>
}